package com.woniuxy.food.app.apiImpl;

import cn.hutool.core.bean.BeanUtil;
import com.woniuxy.cloud.mall95.log.Log;
import com.woniuxy.food.client.foodpropclient.FoodPropQueryClient;
import com.woniuxy.food.client.result.ClientFoodPropDto;
import com.woniuxy.food.service.FoodPropService;
import com.woniuxy.food.service.servicedto.ServiceFoodPropDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import result.Result;

import java.util.List;

@RestController
public class FoodPropQueryClientApiImpl implements FoodPropQueryClient {
    @Autowired
    private FoodPropService foodPropService;
    @Override
    @Log("根据菜品spuID查询全部菜品属性")
    public Result<List<ClientFoodPropDto>> searchFoodPropBySpuId(Integer storeId, Integer spuId) {
        List<ServiceFoodPropDto> serviceFoodPropDtos = foodPropService.searchFoodPropBySpuId(storeId, spuId);
        List<ClientFoodPropDto> clientFoodPropDtos = BeanUtil.copyToList(serviceFoodPropDtos, ClientFoodPropDto.class);
        return Result.success(clientFoodPropDtos);
    }
}
